@tailwind base;
@tailwind components;
@tailwind utilities;

/* Custom CSS Variables for theming */
:root {
  --bg-primary: 255, 255, 255;
  --bg-secondary: 249, 250, 251;
  --bg-tertiary: 243, 244, 246;
  --text-primary: 17, 24, 39;
  --text-secondary: 107, 114, 128;
  --text-tertiary: 156, 163, 175;
  --border-color: 229, 231, 235;
  --accent-color: 59, 130, 246;
  --accent-hover: 37, 99, 235;
}

[data-theme="dark"] {
  --bg-primary: 17, 24, 39;
  --bg-secondary: 31, 41, 55;
  --bg-tertiary: 55, 65, 81;
  --text-primary: 243, 244, 246;
  --text-secondary: 189, 195, 201;
  --text-tertiary: 156, 163, 175;
  --border-color: 75, 85, 99;
  --accent-color: 96, 165, 250;
  --accent-hover: 59, 130, 246;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: rgb(var(--bg-primary));
  color: rgb(var(--text-primary));
  font-size: 14px;
  line-height: 1.6;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(var(--bg-tertiary), 0.5);
}

::-webkit-scrollbar-thumb {
  background: rgba(var(--text-tertiary), 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--text-tertiary), 0.5);
}

/* Editor specific styles */
.milkdown {
  height: 100%;
  width: 100%;
}

.milkdown-content {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100%;
}

.milkdown-content:focus {
  outline: none;
}

/* AI Context Menu */
.ai-context-menu {
  position: fixed;
  background: rgb(var(--bg-primary));
  border: 1px solid rgb(var(--border-color));
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: 8px 0;
  z-index: 1000;
  min-width: 200px;
}

.ai-menu-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  color: rgb(var(--text-primary));
}

.ai-menu-item:hover {
  background-color: rgba(var(--accent-color), 0.1);
}

.ai-menu-item .icon {
  margin-right: 12px;
  font-size: 16px;
}

.ai-menu-item .label {
  font-size: 14px;
}

/* Loading states */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(var(--border-color), 0.3);
  border-radius: 50%;
  border-top-color: rgb(var(--accent-color));
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* File tree styling */
.file-tree {
  height: 100%;
  overflow-y: auto;
  padding: 8px 0;
}

.file-tree-item {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.file-tree-item:hover {
  background-color: rgba(var(--accent-color), 0.1);
}

.file-tree-item.active {
  background-color: rgba(var(--accent-color), 0.2);
  border-left: 3px solid rgb(var(--accent-color));
}

.file-tree-item .icon {
  margin-right: 8px;
  font-size: 14px;
  color: rgb(var(--text-secondary));
}

.file-tree-item .name {
  font-size: 13px;
  color: rgb(var(--text-primary));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  background-color: rgb(var(--bg-secondary));
  border-top: 1px solid rgb(var(--border-color));
  font-size: 12px;
  color: rgb(var(--text-secondary));
  height: 24px;
}

.status-bar-left,
.status-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Markdown content styling */
.markdown-content h1 {
  font-size: 2em;
  font-weight: bold;
  margin: 0.5em 0;
  padding-bottom: 0.3em;
  border-bottom: 1px solid rgb(var(--border-color));
}

.markdown-content h2 {
  font-size: 1.5em;
  font-weight: bold;
  margin: 0.5em 0;
  padding-bottom: 0.3em;
  border-bottom: 1px solid rgb(var(--border-color));
}

.markdown-content h3 {
  font-size: 1.25em;
  font-weight: bold;
  margin: 0.5em 0;
}

.markdown-content p {
  margin: 1em 0;
}

.markdown-content code {
  background-color: rgba(var(--bg-tertiary), 0.5);
  padding: 0.2em 0.4em;
  border-radius: 3px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.9em;
}

.markdown-content pre {
  background-color: rgba(var(--bg-tertiary), 0.5);
  padding: 1em;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1em 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
}

.markdown-content blockquote {
  border-left: 4px solid rgb(var(--accent-color));
  padding-left: 1em;
  margin: 1em 0;
  color: rgb(var(--text-secondary));
}

.markdown-content ul,
.markdown-content ol {
  margin: 1em 0;
  padding-left: 2em;
}

.markdown-content li {
  margin: 0.25em 0;
}

.markdown-content a {
  color: rgb(var(--accent-color));
  text-decoration: none;
}

.markdown-content a:hover {
  text-decoration: underline;
}

.markdown-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.markdown-content th,
.markdown-content td {
  border: 1px solid rgb(var(--border-color));
  padding: 8px 12px;
  text-align: left;
}

.markdown-content th {
  background-color: rgba(var(--bg-tertiary), 0.5);
  font-weight: bold;
}

/* Focus mode */
.focus-mode .milkdown-content > :not(.focused-paragraph) {
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

.focus-mode .milkdown-content > .focused-paragraph {
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* Typewriter mode */
.typewriter-mode .milkdown-content {
  padding-top: 50vh;
  padding-bottom: 50vh;
}

/* Print styles */
@media print {
  .sidebar,
  .status-bar {
    display: none;
  }

  .milkdown-content {
    padding: 0;
    max-width: none;
  }
}